<?php
class ResetPasswordRequest extends Zend_Db_Table_Abstract {
	
	protected $_primary = "id";
	protected $_name = "reset_password_request";
	
	/**
	 * Add new reset password entry to database.
	 */
	public function addEntry($data) {
		return $this->insert($data);
	}
	
	/**
	 * Find active reset password request by key.
	 * 
	 * @param $key unique key
	 */
	public function findActiveByKey($key) {
		$select = $this->select()->where("key=?", $key)
		->where("status=?", 'active');
		return $this->fetchRow($select);
	}
	
	/**
	 * Update access date of the reset password request.
	 * 
	 * @param $inst
	 * @param $accessed
	 */
	public function updateAccessDate($inst, $accessed) {
		$inst->accessed = $accessed;
		$inst->save();
	}
}
?>